package com.zrwl.poscloud.xo.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zrwl.poscloud.base.entity.EmployeeAccount;
import com.zrwl.poscloud.base.superI.SuperMapper;
import com.zrwl.poscloud.xo.vo.EmployeeAccountVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

/**
 * 持卡人员账户 Mapper类
 *
 * @author 刘思童 AutoGenerate
 * @date 2021-07-26
 */
public interface EmployeeAccountMapper extends SuperMapper<EmployeeAccount> {

    IPage<EmployeeAccountVO> getEmployeeAccountList(Page page, @Param("param") EmployeeAccountVO employeeAccountVO);

    /**
     * @param batchUid     补贴批次id
     * @param validDate    新的账户有效时间
     * @param oldValidDate 旧的账户有效时间
     * @return
     */
    int updateSubsidyAccountValidDate(@Param("batchUid") String batchUid, @Param("validDate") Timestamp validDate, @Param("oldValidDate") Timestamp oldValidDate);

    List<EmployeeAccountVO> checkAccountBalance(@Param("balance") double balance);


    @Update("<script>" +
            " UPDATE t_employee_account t" +
            " set t.update_time= #{updateTime},t.status=#{status} WHERE t.employee_uid=#{employeeUid} " +
            "</script>"
    )
    int updateStatusByEmployeeUid(@Param("employeeUid") String employeeUid, @Param("status") int status, @Param("updateTime") Date date);

    @Select("<script>" +
            " SELECT * FROM t_employee_account WHERE status=1 AND employee_uid=#{employeeUid} " +
            "</script>"
    )
    List<EmployeeAccountVO> getEmployeeAccountInfo(@Param("employeeUid") String employeeUid);
}
